﻿<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/MasterPage.master"
    Inherits="InStoreDataMeasures_MeasuresGroup_Item" CodeFile="MeasuresGroup_Item_List.aspx.cs" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <title>指标项维护</title>
    <script language="javascript" type="text/javascript">
        function expandcollapse(obj, row) {
            var div = document.getElementById(obj);
            var img = document.getElementById('img' + obj);

            if (div.style.display == "none") {
                div.style.display = "block";
                if (row == 'alt') {
                    img.src = "../images/collapse.gif";
                }
                else {
                    img.src = "../images/collapse.gif";
                }
                //img.alt = "Close to view other Customers";
                img.alt = "关闭查看指标明细";
            }
            else {
                div.style.display = "none";
                if (row == 'alt') {
                    img.src = "../images/expand.gif";
                }
                else {
                    img.src = "../images/expand.gif";
                }
                img.alt = "展开查看指标明细";
            }
        }
        function setRadio(nowRadio) {
            var myForm, objRadio;
            myForm = document.forms[0];
            //alert(myForm);
            for (var i = 0; i < myForm.length; i++) {
                if (myForm.elements[i].type == "radio") {
                    objRadio = myForm.elements[i];
                    ///alert(objRadio.name);
                    if (objRadio != nowRadio && objRadio.name.indexOf("gvChannelType") > -1 && objRadio.name.indexOf("RadioButton1") > -1) {
                        //alert(objRadio.name);
                        if (objRadio.checked) {
                            objRadio.checked = false;
                        }
                    }
                }
            }
        }

       
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <script>


        /*  
        将Date/String类型,解析为String类型.  
        传入String类型,则先解析为Date类型  
        不正确的Date,返回 ''  
        如果时间部分为0,则忽略,只返回日期部分.  
        */
        function formatDate(v) {
            if (v instanceof Date) {
                var y = v.getFullYear();
                var m = v.getMonth() + 1;
                var d = v.getDate();
                var h = v.getHours();
                var i = v.getMinutes();
                var s = v.getSeconds();
                var ms = v.getMilliseconds();
                if (ms > 0)
                    return y + '-' + m + '-' + d + ' ' + h + ':' + i + ':' + s
						+ '.' + ms;
                if (h > 0 || i > 0 || s > 0)
                    return y + '-' + m + '-' + d + ' ' + h + ':' + i + ':' + s;
                return y + '-' + m + '-' + d;
            }
            return '';
        }

        $(function () {
            var dlg = $('#dd').dialog({
                title: '指标项维护',
                closed: true,
                buttons: [{
                    text: '保存',
                    handler: function () {
                        $get('<%=btnSaveItem.ClientID %>').click();
                    }
                }, {
                    text: '返回',
                    handler: function () {
                        $('#dd').dialog('close');
                    }
                }]
            }); dlg.parent().appendTo(jQuery("form:first"));
        });
        function open1() {
            $('#dd').dialog('open');
        }
        function close1() {
            $('#dd').dialog('close');
        }
    </script>
    <asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server">
    </asp:ScriptManagerProxy>
    <asp:UpdatePanel UpdateMode="Conditional" ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <table id="wsd_inputtable" style="width: 100%">
                <tr>
                    <td class="tabletitle" colspan="6">
                        查询</td>
                </tr>
                <tr>
                    <td class="tablefield">
                        有效:
                    </td>
                    <td>
                        <asp:DropDownList ID="ddlValid" runat="server">
                            <asp:ListItem Value="">--全部--</asp:ListItem>
                            <asp:ListItem Selected="True" Value="1">--有效--</asp:ListItem>
                            <asp:ListItem Value="0">--无效--</asp:ListItem>
                        </asp:DropDownList>
                    </td>
                    <td class="tablefield">
                        <input id="txtHidOrg" type="hidden" runat="server" />
                        <input id="txtHidUsers" type="hidden" runat="server" />
                        关键字</td>
                    <td>
                        <asp:TextBox ID="txt_key" runat="server" ToolTip="输入指标项代码或名称"></asp:TextBox>
                    </td>
                    <td class="tablefield">
                        &nbsp;</td>
                    <td>
                        <asp:Button ID="btnQuery" runat="server" class="wsd_button2" CausesValidation="false"  
                            OnClick="btnQuery_Click" Text="<%$resources:language,btn_Query %>" />
                    </td>
                </tr>
               
            </table>
            <br />
             <table id="wsd_inputtable" width="100%">
               <tr>
                    <td class="tabletitle" colspan="6">
                        指标项
                    </td>
                </tr>
            </table>
            <table id="wsd_listtable" width="100%">
             
                <tr>
                    <td style="width: 100%">
                        <asp:GridView BorderWidth="0" Width="100%" ID="gvITEM" runat="server" AutoGenerateColumns="False"
                            EmptyDataText="没有可显示的数据." EmptyDataRowStyle-Font-Bold="true" EmptyDataRowStyle-HorizontalAlign="Center"
                            EnableEmptyContentRender="true" OnSelectedIndexChanged="gvITEM_SelectedIndexChanged"
                            OnRowDataBound="gvITEM_RowDataBound" DataKeyNames="ID" GridLines="None">
                            <HeaderStyle CssClass="titlist" />
                            <EmptyDataRowStyle HorizontalAlign="Center" Font-Bold="True"></EmptyDataRowStyle>
                            <Columns>
                                <asp:TemplateField>
                                    <ItemTemplate>
                                        <a href="javascript:expandcollapse('div<%# Eval("ID") %>', 'one');">
                                            <img id="imgdiv<%# Eval("ID") %>" alt="点击展开或隐藏客户 <%# Eval("ID") %>" width="9px" border="0"
                                                src="../images/expand.gif" />
                                        </a>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="指标项代码" ShowHeader="False" ItemStyle-Width="30%">
                                    <ItemTemplate>
                                        <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="false" OnClientClick="open1()"
                                            CommandName="Select" Text='<%# Eval("CODE") %>'></asp:LinkButton>
                                    </ItemTemplate>
                                    <ControlStyle Font-Underline="False" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="指标项名称" ShowHeader="False" ItemStyle-Width="30%">
                                    <ItemTemplate>
                                        <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="false" OnClientClick="open1()"
                                            CommandName="Select" Text='<%# Eval("NAME") %>'></asp:LinkButton>
                                    </ItemTemplate>
                                    <ControlStyle Font-Underline="False" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="有效">
                                    <ItemTemplate>
                                        <b>
                                            <%# (bool)Eval("Active") ? "<font size='3' color='green'>√</font>" : "<font size='3' color='red'>×</font>"%></b>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="操作">
                                    <ItemTemplate>
                                        <asp:LinkButton ID="LinkButton3" runat="server" CommandArgument='' CausesValidation="false"
                                            CommandName="Select" Text='分配指标明细' PostBackUrl='<%#"MeasuresDetail_DragSelect_List.aspx?IID="+Eval("ID") %>'>
                                        </asp:LinkButton>
                                    </ItemTemplate>
                                    <ControlStyle Font-Underline="False" />
                                </asp:TemplateField>
                                <asp:TemplateField>
                                    <ItemTemplate>
                                        <tr id="div<%# Eval("ID") %>" style="display: none;">
                                            <td colspan="100%">
                                                <div style="position: relative; left: 15px; overflow: auto; width: 97%">
                                                    <asp:GridView BorderWidth="0" Width="100%" ID="gvDETAIL" runat="server" AutoGenerateColumns="False"
                                                        EmptyDataText="没有可显示的数据." EmptyDataRowStyle-Font-Bold="true" EmptyDataRowStyle-HorizontalAlign="Center"
                                                        OnRowDataBound="Grid_RowDataBound" EnableEmptyContentRender="true" RowStyle-Wrap="false">
                                                        <HeaderStyle CssClass="titlist" />
                                                        <Columns>
                                                            <asp:BoundField HeaderText="编号" DataField="CODE" ReadOnly="true" />
                                                            <asp:TemplateField HeaderText="明细名称">
                                                                <ItemTemplate>
                                                                    <%# Eval("NAME")%>
                                                                </ItemTemplate>
                                                            </asp:TemplateField>
                                                            <asp:TemplateField HeaderText="显示类型">
                                                                <ItemTemplate>
                                                                    <%#new Jumpton.SFA.Server.BusinessRule.InStoreDataMeasures.MeasuresGroupItemDetailManager().getInputType(Eval("INPUTTYPE").ToString())%>
                                                                </ItemTemplate>
                                                            </asp:TemplateField>
                                                            <asp:BoundField HeaderText="下拉值" DataField="DROPDOWNVALUE" ControlStyle-Width="40" />
                                                            <asp:TemplateField HeaderText="是否拍照">
                                                                <ItemTemplate>
                                                                    <b>
                                                                        <%# (bool)Eval("ISPHOTO") ? "<font size='3' color='green'>√</font>" : "<font size='3' color='red'>×</font>"%></b>
                                                                </ItemTemplate>
                                                            </asp:TemplateField>
                                                            <asp:TemplateField HeaderText="是否必填">
                                                                <ItemTemplate>
                                                                    <b>
                                                                        <%# (bool)Eval("ISREQUIRED")? "<font size='3' color='green'>√</font>" : "<font size='3' color='red'>×</font>"%></b>
                                                                </ItemTemplate>
                                                            </asp:TemplateField>
                                                            <asp:BoundField HeaderText="备注" DataField="REMARK" ReadOnly="true" />
                                                            <asp:TemplateField HeaderText="有效">
                                                                <ItemTemplate>
                                                                    <b>
                                                                        <%# (bool)Eval("ACTIVE") ? "<font size='3' color='green'>√</font>" : "<font size='3' color='red'>×</font>"%>
                                                                    </b>
                                                                </ItemTemplate>
                                                                <HeaderStyle HorizontalAlign="Center" />
                                                                <ItemStyle HorizontalAlign="Center" />
                                                            </asp:TemplateField>
                                                        </Columns>
                                                        <RowStyle CssClass="evenline" />
                                                        <AlternatingRowStyle CssClass="oddline" />
                                                        <PagerSettings Visible="true" />
                                                    </asp:GridView>
                                                </div>
                                            </td>
                                        </tr>
                                    </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                            <RowStyle CssClass="evenline" />
                            <AlternatingRowStyle CssClass="oddline" />
                            <PagerSettings Visible="False" Mode="NumericFirstLast" />
                        </asp:GridView>
                    </td>
                </tr>
            </table>
            <br />
            <table id="wsd_inputtable" style="width: 100%">
                <tr>
                    <td width="100%" class="tabletitle">
                        操作选项
                    </td>
                </tr>
                <tr>
                    <td class="buttonarea" style="text-align: right;">
                        <asp:Button ID="btnSave" runat="server" class="wsd_button2" Text="保 存" OnClick="btnSave_Click" />
                        <input class="wsd_button2" onclick="window.location.href='MeasuresGroup_List.aspx';"
                            type="button" value="返  回" />
                        <asp:Button ID="btnAddItem" runat="server" class="wsd_button2" Text="新增指标项" OnClientClick="open1();"
                            CausesValidation="false" OnClick="btnAddItem_Click" />
                    </td>
                </tr>
            </table>
        </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="btnSave" EventName="Click" />
            <%-- <asp:AsyncPostBackTrigger ControlID="btnSaveItem" EventName="Click" />--%>
        </Triggers>
    </asp:UpdatePanel>
    <div id="dd" style="width: 350px; height: 280px;">
        <asp:UpdatePanel UpdateMode="Conditional" ID="UpdatePanel2" runat="server">
            <ContentTemplate>
                <table id="Table2" style="width: 100%; text-align: center;">
                    <tr>
                        <td class="tabletitle" style="width: 100%; text-align: left;">
                            <font color="red" size="2"><b>提示:*为必填项</b></font>
                        </td>
                        <td class="tabletitle">
                        </td>
                    </tr>
                </table>
                <table id="wsd_inputtable" style="width: 100%; border: 0px;">
                    <tr>
                        <td>
                            <center>
                                <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataSourceID="ObjectDataSource1"
                                    DefaultMode="Insert" OnDataBound="DetailsView1_DataBound" GridLines="None" BorderWidth="0px" EnableModelValidation="True">
                                    <PagerStyle HorizontalAlign="Right"></PagerStyle>
                                    <Fields>
                                        <asp:TemplateField HeaderText="代码:<font color=red>*</font>">
                                            <ItemTemplate>
                                                <asp:TextBox ID="txtCode" runat="server" Text='<%# Bind("CODE") %>'></asp:TextBox>
                                                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" Display="Dynamic"
                                                    ErrorMessage="代码不能为空" ControlToValidate="txtCode"></asp:RequiredFieldValidator>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="名称:<font color=red>*</font>">
                                            <ItemTemplate>
                                                <asp:TextBox ID="txtName" runat="server" Text='<%# Bind("NAME") %>'></asp:TextBox>
                                                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" Display="Dynamic"
                                                    ErrorMessage="项名不能为空" ControlToValidate="txtName"></asp:RequiredFieldValidator>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="顺序:">
                                            <ItemTemplate>
                                                <asp:TextBox ID="txtSEQUENCE" runat="server" Text='<%# Bind("SEQUENCE") %>'></asp:TextBox>
                                                <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtSEQUENCE"
                                                    Display="Dynamic" ErrorMessage="顺序值应为数字!" meta:resourcekey="RegularExpressionValidator1Resource1"
                                                    ValidationExpression="^(\d{1,3}(,\d\d\d)*(\.\d+)?|\d+(\.\d+)?)$"></asp:RegularExpressionValidator>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="拜访状态:">
                                            <ItemTemplate>
                                                <asp:DropDownList ID="ddl_state" runat="server">
                                                    <asp:ListItem Text="拜访前" Value="1"></asp:ListItem>
                                                    <asp:ListItem Text="拜访中" Value="2"></asp:ListItem>
                                                    <asp:ListItem Text="拜访后" Value="3"></asp:ListItem>
                                                </asp:DropDownList>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="有效:">
                                            <ItemTemplate>
                                                <asp:CheckBox runat="server" ID="chkValid" Checked='<%# Bind("ACTIVE") %>' />
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                    </Fields>
                                    <RowStyle CssClass="tablefield" />
                                </asp:DetailsView>
                                <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" DataObjectTypeName="Jumpton.SFA.Server.Entity.MEASURE_ITEMS"
                                    DeleteMethod="Save" InsertMethod="Save" SelectMethod="Load" TypeName="Jumpton.SFA.Server.BusinessRule.InStoreDataMeasures.MeasuresGroupItemManager"
                                    UpdateMethod="Save">
                                    <SelectParameters>
                                        <asp:ControlParameter ControlID="gvITEM" DefaultValue="" Name="ID" PropertyName="SelectedValue"
                                            Type="Int32" />
                                    </SelectParameters>
                                </asp:ObjectDataSource>
                            </center>
                        </td>
                    </tr>
                </table>
                <div style="display: none;">
                    <table id="Table1" style="width: 100%">
                        <tr>
                            <td height="10px" width="100%" class="tabletitle">
                                操作选项
                            </td>
                        </tr>
                        <tr>
                            <td class="buttonarea">
                                <asp:Button ID="btnSaveItem" runat="server" class="wsd_button2" Text="保  存" OnClick="btnSaveItem_Click" />
                            </td>
                        </tr>
                    </table>
                </div>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="gvITEM" EventName="SelectedIndexChanged" />
                <asp:AsyncPostBackTrigger ControlID="btnSaveItem" EventName="Click" />
                <asp:AsyncPostBackTrigger ControlID="btnAddItem" EventName="Click" />
            </Triggers>
        </asp:UpdatePanel>
    </div>
</asp:Content>
